package cn.anecansaitin.not_enough_harness.common.item;

import cn.anecansaitin.not_enough_harness.NotEnoughHarness;
import cn.anecansaitin.not_enough_harness.common.harness_data.*;
import net.minecraft.core.component.DataComponentType;
import net.minecraft.core.registries.Registries;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;

public class ModComponents {
    public static final DeferredRegister.DataComponents COMPONENTS = DeferredRegister.createDataComponents(Registries.DATA_COMPONENT_TYPE, NotEnoughHarness.MOD_ID);
    public static final DeferredHolder<DataComponentType<?>, DataComponentType<HarnessCapabilityCD>> HARNESS_CAPABILITY_CD = COMPONENTS.registerComponentType(
            "harness_capability_cd",
            builder -> builder.persistent(HarnessCapabilityCD.CODEC).networkSynchronized(HarnessCapabilityCD.STREAM_CODEC)
    );

    public static final DeferredHolder<DataComponentType<?>, DataComponentType<HarnessSpeed>> HARNESS_SPEED = COMPONENTS.registerComponentType(
            "harness_speed",
            builder -> builder.persistent(HarnessSpeed.CODEC).networkSynchronized(HarnessSpeed.STREAM_CODEC)
    );

    public static final DeferredHolder<DataComponentType<?>, DataComponentType<SprintableHarness>> SPRINTABLE_HARNESS = COMPONENTS.registerComponentType(
            "sprintable_harness",
            builder -> builder.persistent(SprintableHarness.CODEC).networkSynchronized(SprintableHarness.STREAM_CODEC)
    );

    public static final DeferredHolder<DataComponentType<?>, DataComponentType<RushTriggerHarness>> RUSH_TRIGGER_HARNESS = COMPONENTS.registerComponentType(
            "rush_trigger_harness",
            builder -> builder.persistent(RushTriggerHarness.CODEC).networkSynchronized(RushTriggerHarness.STREAM_CODEC)
    );

    public static final DeferredHolder<DataComponentType<?>, DataComponentType<RushTriggerHarnessDirection>> RUSH_TRIGGER_HARNESS_DIRECTION = COMPONENTS.registerComponentType(
            "rush_trigger_harness_direction",
            builder -> builder.persistent(RushTriggerHarnessDirection.CODEC).networkSynchronized(RushTriggerHarnessDirection.STREAM_CODEC)
    );

    public static void register(IEventBus bus) {
        COMPONENTS.register(bus);
    }
}
